<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    {js href='__STATIC__/jquery/jquery-1.11.0.min.js' /}
    {js href='__STATIC__/layui/layui.js' /}
    {CSS href="__STATIC__/layui/css/layui.css" /}
    {CSS href="__ADDONSTATIC__/css/style.css" /}
</head>
{if condition="isMobile() eq true"}
<style>
    .layui-btn{margin-bottom: 5px;}
</style>
<script>
    $(function () {
        $('.vote_time').remove();
        $('.bm_id').remove();
    })
</script>
{/if}
<body style="padding: 0px 10px;">
<table class="layui-table" lay-skin="nob" lay-size="sm">
    <thead>
    <tr>
        <th class="bm_id">编号</th>
        <th>呢称</th>
        <th>电话</th>
        <th>封面</th>
        <th>票量</th>
        <th class="vote_time">时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="data" id="vo"}
    <tr>
        <td class="bm_id">{$vo.bm_id}</td>
        <td>{$vo.username}</td>
        <td>{$vo.phone}</td>
        <td><img class="vote_list_cover" onclick="openImsg(this)" src="{$vo.cover}"></td>
        <td>{$vo.vote_total}</td>
        <td class="vote_time">{:date('d H:i',strtotime($vo.create_time))}</td>
        <td>
            {if condition="$vo.status eq '0'"}
            <button onclick="voteHidden('{$vo.bm_id}','1')" class="layui-btn layui-btn-mini layui-btn-danger" href="">显示</button>
            {else/}
            <button onclick="voteHidden('{$vo.bm_id}','0')" class="layui-btn layui-btn-mini layui-btn-danger" href="">隐藏</button>
            {/if}

            <button onclick="voteSetinc('{$vo.bm_id}')" class="layui-btn layui-btn-mini layui-btn-normal" href="">增票</button>
        </td>
    </tr>
    {/volist}
    </tbody>
</table>
{$data->render()}
</body>
<script>
    var layer;
    layui.use('layer',function () {
        layer = layui.layer;
    })
    function voteHidden(id,status) {
        $.post("{:addonUrl('voteHidden')}",{'id':id,'status':status},function (res) {
            layer.msg(res.msg)
        })
    }
    function voteSetinc(id) {
        layer.prompt({title: '请输入增加票数', formType: 0,value:1}, function(vote, index){
            $.post("{:addonUrl('voteSetinc')}",{'id':id,'vote':vote},function (res) {
                layer.close(index)
                layer.msg(res.msg)
            })
        });
    }
    function openImsg(obj) {
        var data={
            "title": "图片",
            "id": 1,
            "start": 0,
            "data": [
                {
                    "alt": "图片",
                    "pid": 666,
                    "src": obj.src,
                    "thumb": obj.src
                }
            ]
        }
        layer.photos({
            photos: data,
        });
    }
</script>
</html>